﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IntelBillboard
{
    class UIController
    {
        const int totalNoAdvertisements = 15;
        const int defaultAdNo = 2;
        
        int advertismentCounter;

        MenuBar menubar;
        UICase currentUI;
        UICase[] UIList = new UICase[totalNoAdvertisements];

        public UIController() 
        {
            menubar = new MenuBar();

            //init all UICase
            for(int i=0; i<totalNoAdvertisements; i++)
                UIList[i] = new UICase();

            //set special UICase
            UIList[4] = new UICase_Transformer();
            UIList[10] = new UICase_Football();

            //set default current UI
            advertismentCounter = defaultAdNo;
            currentUI = UIList[advertismentCounter];
        }

        public int getCounter()
        {
            return advertismentCounter;
        }

        
        public void increaseCounter() {
            if (advertismentCounter < totalNoAdvertisements - 1)
            {
                advertismentCounter++;
                Console.WriteLine("ad counter No: " + advertismentCounter);
            }
            else
            {
                advertismentCounter = 0;
                Console.WriteLine("ad counter No: " + advertismentCounter);
            }
        }
        

        public void decreaseCounter()
        {
            if (advertismentCounter > 0)
            {
                advertismentCounter--;
                Console.WriteLine("ad counter No: " + advertismentCounter);
            }
            else
            {
                advertismentCounter = totalNoAdvertisements - 1;
                Console.WriteLine("ad counter No: " + advertismentCounter);
            }
        }

        public UICase getCurrentUI()
        {
            return currentUI;
        }

        public void setCurrentUI()
        {
            currentUI = UIList[advertismentCounter];
            currentUI.reset();                      
        }

        public void setCounter(int value)
        {
            this.advertismentCounter = value;
        }

        public MenuBar getMenuBar()
        {
            return menubar;
        }

    }
}
